// Upgrade NOTE: commented out 'float4 unity_DynamicLightmapST', a built-in variable
// Upgrade NOTE: commented out 'float4 unity_LightmapST', a built-in variable
// Upgrade NOTE: commented out 'float4 unity_ShadowFadeCenterAndType', a built-in variable
// Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Upgrade NOTE: replaced 'unity_World2Shadow' with 'unity_WorldToShadow'

Shader "Hidden/TerrainEngine/Splatmap/Standard-AddPass" {
Properties {
[HideInInspector]  _Control ("Control (RGBA)", 2D) = "red" { }
[HideInInspector]  _Splat3 ("Layer 3 (A)", 2D) = "white" { }
[HideInInspector]  _Splat2 ("Layer 2 (B)", 2D) = "white" { }
[HideInInspector]  _Splat1 ("Layer 1 (G)", 2D) = "white" { }
[HideInInspector]  _Splat0 ("Layer 0 (R)", 2D) = "white" { }
[HideInInspector]  _Normal3 ("Normal 3 (A)", 2D) = "bump" { }
[HideInInspector]  _Normal2 ("Normal 2 (B)", 2D) = "bump" { }
[HideInInspector]  _Normal1 ("Normal 1 (G)", 2D) = "bump" { }
[HideInInspector]  _Normal0 ("Normal 0 (R)", 2D) = "bump" { }
[HideInInspector] [Gamma]  _Metallic0 ("Metallic 0", Range(0,1)) = 0
[HideInInspector] [Gamma]  _Metallic1 ("Metallic 1", Range(0,1)) = 0
[HideInInspector] [Gamma]  _Metallic2 ("Metallic 2", Range(0,1)) = 0
[HideInInspector] [Gamma]  _Metallic3 ("Metallic 3", Range(0,1)) = 0
[HideInInspector]  _Smoothness0 ("Smoothness 0", Range(0,1)) = 1
[HideInInspector]  _Smoothness1 ("Smoothness 1", Range(0,1)) = 1
[HideInInspector]  _Smoothness2 ("Smoothness 2", Range(0,1)) = 1
[HideInInspector]  _Smoothness3 ("Smoothness 3", Range(0,1)) = 1
}
SubShader { 
 Tags { "QUEUE"="Geometry-99" "IGNOREPROJECTOR"="true" "RenderType"="Opaque" }
 Pass {
  Name "FORWARD"
  Tags { "LIGHTMODE"="ForwardBase" "QUEUE"="Geometry-99" "IGNOREPROJECTOR"="true" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
  ZWrite Off
  Blend One One
  GpuProgramID 33281
CGPROGRAM
//#pragma target 4.0

#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"
#define conv_mxt4x4_0(mat4x4) float4(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x,mat4x4[3].x)
#define conv_mxt4x4_1(mat4x4) float4(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y,mat4x4[3].y)
#define conv_mxt4x4_2(mat4x4) float4(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z,mat4x4[3].z)
#define conv_mxt4x4_3(mat4x4) float4(mat4x4[0].w,mat4x4[1].w,mat4x4[2].w,mat4x4[3].w)


#define CODE_BLOCK_VERTEX
//uniform float4 _Time;
//uniform float4 _SinTime;
//uniform float4 _CosTime;
//uniform float4 unity_DeltaTime;
//uniform float3 _WorldSpaceCameraPos;
//uniform float4 _ProjectionParams;
//uniform float4 _ScreenParams;
//uniform float4 _ZBufferParams;
//uniform float4 unity_OrthoParams;
//uniform float4 unity_CameraWorldClipPlanes[6];
//uniform mat4x4 unity_CameraProjection;
//uniform mat4x4 unity_CameraInvProjection;
//uniform float4 _WorldSpaceLightPos0;
//uniform float4 _LightPositionRange;
//uniform float4 unity_4LightPosX0;
//uniform float4 unity_4LightPosY0;
//uniform float4 unity_4LightPosZ0;
//uniform float4 unity_4LightAtten0;
//uniform float4 unity_LightColor[8];
//uniform float4 unity_LightPosition[8];
//uniform float4 unity_LightAtten[8];
//uniform float4 unity_SpotDirection[8];
//uniform float4 unity_SHAr;
//uniform float4 unity_SHAg;
//uniform float4 unity_SHAb;
//uniform float4 unity_SHBr;
//uniform float4 unity_SHBg;
//uniform float4 unity_SHBb;
//uniform float4 unity_SHC;
uniform float3 unity_LightColor0;
uniform float3 unity_LightColor1;
uniform float3 unity_LightColor2;
uniform float3 unity_LightColor3;
uniform float4x4 unity_ShadowSplitSpheres;
uniform float4 unity_ShadowSplitSqRadii;
//uniform float4 unity_LightShadowBias;
//uniform float4 _LightSplitsNear;
//uniform float4 _LightSplitsFar;
uniform mat4x4x4 unity_WorldToShadow;
//uniform float4 _LightShadowData;
// uniform float4 unity_ShadowFadeCenterAndType;
//uniform mat4x4 UNITY_MATRIX_MVP;
//uniform mat4x4 UNITY_MATRIX_MV;
//uniform mat4x4 UNITY_MATRIX_IT_MV;
//uniform mat4x4 unity_ObjectToWorld;
uniform mat4x4 unity_WorldToObject;
//uniform float4 unity_LODFade;
//uniform float4 unity_WorldTransformParams;
//uniform mat4x4 glstate_matrix_transpose_modelview0;
//uniform mat4x4 UNITY_MATRIX_P;
//uniform float4 glstate_lightmodel_ambient;
//uniform mat4x4 unity_MatrixV;
//uniform mat4x4 unity_MatrixVP;
//uniform float4 unity_AmbientSky;
//uniform float4 unity_AmbientEquator;
//uniform float4 unity_AmbientGround;
//uniform float4 unity_FogColor;
//uniform float4 unity_FogParams;
// uniform float4 unity_LightmapST;
// uniform float4 unity_DynamicLightmapST;
//uniform float4 unity_SpecCube0_BoxMax;
//uniform float4 unity_SpecCube0_BoxMin;
//uniform float4 unity_SpecCube0_ProbePosition;
//uniform float4 unity_SpecCube0_HDR;
//uniform float4 unity_SpecCube1_BoxMax;
//uniform float4 unity_SpecCube1_BoxMin;
//uniform float4 unity_SpecCube1_ProbePosition;
//uniform float4 unity_SpecCube1_HDR;
uniform float4 unity_ColorSpaceGrey;
//uniform float4 unity_ColorSpaceDouble;
uniform float4 unity_ColorSpaceDielectricSpec;
uniform float4 unity_ColorSpaceLuminance;
//uniform float4 unity_Lightmap_HDR;
uniform float4 unity_DynamicLightmap_HDR;
uniform float4 _LightColor0;
uniform float4 _SpecColor;
uniform float4 _Control_ST;
uniform float _Metallic0;
uniform float _Metallic1;
uniform float _Metallic2;
uniform float _Metallic3;
uniform float _Smoothness0;
uniform float _Smoothness1;
uniform float _Smoothness2;
uniform float _Smoothness3;
uniform float4 _Splat0_ST;
uniform float4 _Splat1_ST;
uniform float4 _Splat2_ST;
uniform float4 _Splat3_ST;
uniform sampler2D _Control;
uniform sampler2D _Splat0;
uniform sampler2D _Splat1;
uniform sampler2D _Splat2;
uniform sampler2D _Splat3;
//uniform samplerCUBE unity_SpecCube0;
struct appdata_t
{
    float4 vertex :POSITION0;
    float3 normal :NORMAL0;
    float4 texcoord :TEXCOORD0;
};

struct OUT_Data_Vert
{
    float4 texcoord :TEXCOORD0;
    float4 texcoord1 :TEXCOORD1;
    float3 texcoord2 :TEXCOORD2;
    float3 texcoord3 :TEXCOORD3;
    float2 texcoord4 :TEXCOORD4;
    float3 texcoord5 :TEXCOORD5;
    float4 texcoord7 :TEXCOORD7;
    float4 vertex :SV_POSITION;
};

struct v2f
{
    float4 texcoord :TEXCOORD0;
    float4 texcoord1 :TEXCOORD1;
    float3 texcoord2 :TEXCOORD2;
    float3 texcoord3 :TEXCOORD3;
    float2 texcoord4 :TEXCOORD4;
    float3 texcoord5 :TEXCOORD5;
};

struct OUT_Data_Frag
{
    float4 color :SV_Target0;
};

float4 t0;
float4 t16_0;
float3 t1;
float t16_2;
float3 t16_3;
float t12;
OUT_Data_Vert vert(appdata_t in_v)
{
    OUT_Data_Vert out_v;
    out_v.vertex = UnityObjectToClipPos(in_v.vertex);
    out_v.texcoord.xy = TRANSFORM_TEX(in_v.texcoord.xy, _Splat0);
    out_v.texcoord.zw = TRANSFORM_TEX(in_v.texcoord.xy, _Splat1);
    out_v.texcoord1.xy = TRANSFORM_TEX(in_v.texcoord.xy, _Splat2);
    out_v.texcoord1.zw = TRANSFORM_TEX(in_v.texcoord.xy, _Splat3);
    t0.x = (in_v.normal.x * conv_mxt4x4_0(unity_WorldToObject).x);
    t0.y = (in_v.normal.x * conv_mxt4x4_1(unity_WorldToObject).x);
    t0.z = (in_v.normal.x * conv_mxt4x4_2(unity_WorldToObject).x);
    t1.x = (in_v.normal.y * conv_mxt4x4_0(unity_WorldToObject).y);
    t1.y = (in_v.normal.y * conv_mxt4x4_1(unity_WorldToObject).y);
    t1.z = (in_v.normal.y * conv_mxt4x4_2(unity_WorldToObject).y);
    t0.xyz = (t0.xyz + t1.xyz);
    t1.x = (in_v.normal.z * conv_mxt4x4_0(unity_WorldToObject).z);
    t1.y = (in_v.normal.z * conv_mxt4x4_1(unity_WorldToObject).z);
    t1.z = (in_v.normal.z * conv_mxt4x4_2(unity_WorldToObject).z);
    t0.xyz = (t0.xyz + t1.xyz);
    t0.xyz = normalize(t0.xyz);
    out_v.texcoord2.xyz = t0.xyz;
    t1.xyz = (in_v.vertex.yyy * conv_mxt4x4_1(unity_ObjectToWorld).xyz);
    t1.xyz = ((conv_mxt4x4_0(unity_ObjectToWorld).xyz * in_v.vertex.xxx) + t1.xyz);
    t1.xyz = ((conv_mxt4x4_2(unity_ObjectToWorld).xyz * in_v.vertex.zzz) + t1.xyz);
    out_v.texcoord3.xyz = ((conv_mxt4x4_3(unity_ObjectToWorld).xyz * in_v.vertex.www) + t1.xyz);
    out_v.texcoord4.xy = TRANSFORM_TEX(in_v.texcoord.xy, _Control);
    t16_2 = (t0.y * t0.y);
    t16_2 = ((t0.x * t0.x) + (-t16_2));
    t16_0 = (t0.yzzx * t0.xyzz);
    t16_3.x = dot(unity_SHBr, t16_0);
    t16_3.y = dot(unity_SHBg, t16_0);
    t16_3.z = dot(unity_SHBb, t16_0);
    out_v.texcoord5.xyz = ((unity_SHC.xyz * float3(t16_2, t16_2, t16_2)) + t16_3.xyz);
    out_v.texcoord7 = float4(0, 0, 0, 0);
    return out_v;
}

#define CODE_BLOCK_FRAGMENT
float3 t0_d;
float4 t10_0;
float4 t16_1;
float4 t2;
float4 t16_2_d;
float4 t10_2;
float4 t16_3_d;
float4 t10_3;
float4 t4;
float t16_4;
float4 t10_4;
float4 t16_5;
float3 t16_6;
float3 t16_7;
float3 t16_8;
float t16_10;
float t16_14;
float t16_19;
float t16_23;
float t27;
float t16_27;
float t16_28;
OUT_Data_Frag frag(v2f in_f)
{
    OUT_Data_Frag out_f;
    t0_d.xyz = ((-in_f.texcoord3.xyz) + _WorldSpaceCameraPos.xyz);
    t27 = dot(t0_d.xyz, t0_d.xyz);
    t27 = rsqrt(t27);
    t16_1.xyz = ((t0_d.xyz * float3(t27, t27, t27)) + _WorldSpaceLightPos0.xyz);
    t0_d.xyz = (float3(t27, t27, t27) * t0_d.xyz);
    t16_28 = dot(t16_1.xyz, t16_1.xyz);
    t16_27 = max(t16_28, 0.00100000005);
    t16_28 = rsqrt(t16_27);
    t16_1.xyz = (float3(t16_28, t16_28, t16_28) * t16_1.xyz);
    t10_2.x = dot(in_f.texcoord2.xyz, in_f.texcoord2.xyz);
    t10_2.x = rsqrt(t10_2.x);
    t10_2.xyz = (t10_2.xxx * in_f.texcoord2.xyz);
    t16_28 = dot(t10_2.xyz, t16_1.xyz);
    t16_1.x = dot(_WorldSpaceLightPos0.xyz, t16_1.xyz);
    t16_27 = max(t16_1.x, 0);
    t16_1.x = dot(t10_2.xyz, t0_d.xyz);
    t16_3_d.x = max(t16_1.x, 0);
    t16_1.x = ((-t16_3_d.x) + 1);
    t16_1.x = (t16_1.x * t16_1.x);
    t16_1.x = (t16_1.x * t16_1.x);
    t16_3_d.x = max(t16_28, 0);
    t16_10 = log2(t16_3_d.x);
    t10_2 = tex2D(_Splat0, in_f.texcoord.xy);
    t10_3 = tex2D(_Control, in_f.texcoord4.xy);
    t16_19 = dot(t10_3, float4(1, 1, 1, 1));
    t16_4 = (t16_19 + 0.00100000005);
    t16_3_d = (t10_3 / float4(t16_4, t16_4, t16_4, t16_4));
    t2 = (t10_2 * t16_3_d.xxxx);
    t2.w = (t2.w * _Smoothness0);
    t10_4 = tex2D(_Splat1, in_f.texcoord.zw);
    t4 = (t16_3_d.yyyy * t10_4);
    t4.w = (t4.w * _Smoothness1);
    t2 = (t2 + t4);
    t10_4 = tex2D(_Splat2, in_f.texcoord1.xy);
    t4 = (t16_3_d.zzzz * t10_4);
    t4.w = (t4.w * _Smoothness2);
    t2 = (t2 + t4);
    t10_4 = tex2D(_Splat3, in_f.texcoord1.zw);
    t4 = (t16_3_d.wwww * t10_4);
    t16_28 = dot(t16_3_d, float4(_Metallic0, _Metallic1, _Metallic2, _Metallic3));
    t4.w = (t4.w * _Smoothness3);
    t2 = (t2 + t4);
    t16_5.x = ((-t2.w) + 1);
    t16_14 = (t16_5.x * t16_5.x);
    t16_3_d.x = max(t16_14, 9.99999975E-05);
    t16_23 = (t16_3_d.x * t16_3_d.x);
    t16_23 = (2 / t16_23);
    t16_23 = (t16_23 + (-2));
    t16_3_d.x = max(t16_23, 9.99999975E-05);
    t16_10 = (t16_10 * t16_3_d.x);
    t16_23 = (t16_3_d.x + 1);
    t16_10 = exp2(t16_10);
    t16_10 = (t16_10 * t16_23);
    t16_23 = (t16_27 * t16_27);
    t16_23 = ((t16_23 * t2.w) + t16_14);
    t16_14 = (t16_5.x * t16_14);
    t16_14 = (((-t16_14) * 0.280000001) + 1);
    t16_23 = (t16_23 * 8);
    t16_27 = ((t16_23 * t16_27) + 9.99999975E-05);
    t16_27 = (t16_10 / t16_27);
    t16_27 = max(t16_27, 9.99999975E-05);
    t16_27 = sqrt(t16_27);
    t16_10 = min(t16_27, 100);
    t16_6.xyz = (t2.xyz + (-unity_ColorSpaceDielectricSpec.xyz));
    t16_6.xyz = ((float3(t16_28, t16_28, t16_28) * t16_6.xyz) + unity_ColorSpaceDielectricSpec.xyz);
    t16_28 = (((-t16_28) * unity_ColorSpaceDielectricSpec.w) + unity_ColorSpaceDielectricSpec.w);
    t16_7.xyz = (float3(t16_28, t16_28, t16_28) * t2.xyz);
    t16_28 = ((-t16_28) + 1);
    t16_28 = (t16_28 + t2.w);
    t16_28 = clamp(t16_28, 0, 1);
    t16_8.xyz = ((-t16_6.xyz) + float3(t16_28, t16_28, t16_28));
    t16_8.xyz = ((t16_1.xxx * t16_8.xyz) + t16_6.xyz);
    t16_1.xyw = ((float3(t16_10, t16_10, t16_10) * t16_6.xyz) + t16_7.xyz);
    t16_1.xyw = (t16_1.xyw * _LightColor0.xyz);
    t16_2_d.xyz = in_f.texcoord2.xyz;
    t16_2_d.w = 1;
    t16_6.x = dot(unity_SHAr, t16_2_d);
    t16_6.y = dot(unity_SHAg, t16_2_d);
    t16_6.z = dot(unity_SHAb, t16_2_d);
    t16_6.xyz = (t16_6.xyz + in_f.texcoord5.xyz);
    t16_6.xyz = max(t16_6.xyz, float3(0, 0, 0));
    t16_3_d.xyz = log2(t16_6.xyz);
    t16_3_d.xyz = (t16_3_d.xyz * float3(0.416666657, 0.416666657, 0.416666657));
    t16_3_d.xyz = exp2(t16_3_d.xyz);
    t16_3_d.xyz = ((t16_3_d.xyz * float3(1.05499995, 1.05499995, 1.05499995)) + float3(-0.0549999997, (-0.0549999997), (-0.0549999997)));
    t16_3_d.xyz = max(t16_3_d.xyz, float3(0, 0, 0));
    t16_6.xyz = (t16_7.xyz * t16_3_d.xyz);
    t16_23 = dot(in_f.texcoord2.xyz, _WorldSpaceLightPos0.xyz);
    t16_27 = max(t16_23, 0);
    t16_1.xyw = ((t16_1.xyw * float3(t16_27, t16_27, t16_27)) + t16_6.xyz);
    t16_23 = dot((-t0_d.xyz), in_f.texcoord2.xyz);
    t16_23 = (t16_23 + t16_23);
    t16_6.xyz = ((in_f.texcoord2.xyz * (-float3(t16_23, t16_23, t16_23))) + (-t0_d.xyz));
    t16_23 = (((-t16_5.x) * 0.699999988) + 1.70000005);
    t16_5.x = (t16_23 * t16_5.x);
    t16_5.x = (t16_5.x * 6);
    t10_0 = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, float4(t16_6.xyz, t16_5.x));
    t16_5.x = (t10_0.w * unity_SpecCube0_HDR.x);
    t16_5.xzw = (t10_0.xyz * t16_5.xxx);
    t16_5.xyz = (t16_5.xzw * float3(t16_14, t16_14, t16_14));
    t16_1.xyw = ((t16_5.xyz * t16_8.xyz) + t16_1.xyw);
    out_f.color.xyz = (float3(t16_19, t16_19, t16_19) * t16_1.xyw);
    out_f.color.w = 1;
    return out_f;
}


ENDCG

}
 Pass {
  Name "FORWARD"
  Tags { "LIGHTMODE"="ForwardAdd" "QUEUE"="Geometry-99" "IGNOREPROJECTOR"="true" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
  ZWrite Off
  Blend One One
  GpuProgramID 103204
CGPROGRAM
//#pragma target 4.0

#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"
#define conv_mxt4x4_0(mat4x4) float4(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x,mat4x4[3].x)
#define conv_mxt4x4_1(mat4x4) float4(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y,mat4x4[3].y)
#define conv_mxt4x4_2(mat4x4) float4(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z,mat4x4[3].z)
#define conv_mxt4x4_3(mat4x4) float4(mat4x4[0].w,mat4x4[1].w,mat4x4[2].w,mat4x4[3].w)


#define CODE_BLOCK_VERTEX
//uniform float4 _Time;
//uniform float4 _SinTime;
//uniform float4 _CosTime;
//uniform float4 unity_DeltaTime;
//uniform float3 _WorldSpaceCameraPos;
//uniform float4 _ProjectionParams;
//uniform float4 _ScreenParams;
//uniform float4 _ZBufferParams;
//uniform float4 unity_OrthoParams;
//uniform float4 unity_CameraWorldClipPlanes[6];
//uniform mat4x4 unity_CameraProjection;
//uniform mat4x4 unity_CameraInvProjection;
//uniform float4 _WorldSpaceLightPos0;
//uniform float4 _LightPositionRange;
//uniform float4 unity_4LightPosX0;
//uniform float4 unity_4LightPosY0;
//uniform float4 unity_4LightPosZ0;
//uniform float4 unity_4LightAtten0;
//uniform float4 unity_LightColor[8];
//uniform float4 unity_LightPosition[8];
//uniform float4 unity_LightAtten[8];
//uniform float4 unity_SpotDirection[8];
//uniform float4 unity_SHAr;
//uniform float4 unity_SHAg;
//uniform float4 unity_SHAb;
//uniform float4 unity_SHBr;
//uniform float4 unity_SHBg;
//uniform float4 unity_SHBb;
//uniform float4 unity_SHC;
uniform float3 unity_LightColor0;
uniform float3 unity_LightColor1;
uniform float3 unity_LightColor2;
uniform float3 unity_LightColor3;
uniform float4x4 unity_ShadowSplitSpheres;
uniform float4 unity_ShadowSplitSqRadii;
//uniform float4 unity_LightShadowBias;
//uniform float4 _LightSplitsNear;
//uniform float4 _LightSplitsFar;
uniform mat4x4x4 unity_WorldToShadow;
//uniform float4 _LightShadowData;
// uniform float4 unity_ShadowFadeCenterAndType;
//uniform mat4x4 UNITY_MATRIX_MVP;
//uniform mat4x4 UNITY_MATRIX_MV;
//uniform mat4x4 UNITY_MATRIX_IT_MV;
//uniform mat4x4 unity_ObjectToWorld;
uniform mat4x4 unity_WorldToObject;
//uniform float4 unity_LODFade;
//uniform float4 unity_WorldTransformParams;
//uniform mat4x4 glstate_matrix_transpose_modelview0;
//uniform mat4x4 UNITY_MATRIX_P;
//uniform float4 glstate_lightmodel_ambient;
//uniform mat4x4 unity_MatrixV;
//uniform mat4x4 unity_MatrixVP;
//uniform float4 unity_AmbientSky;
//uniform float4 unity_AmbientEquator;
//uniform float4 unity_AmbientGround;
//uniform float4 unity_FogColor;
//uniform float4 unity_FogParams;
// uniform float4 unity_LightmapST;
// uniform float4 unity_DynamicLightmapST;
//uniform float4 unity_SpecCube0_BoxMax;
//uniform float4 unity_SpecCube0_BoxMin;
//uniform float4 unity_SpecCube0_ProbePosition;
//uniform float4 unity_SpecCube0_HDR;
//uniform float4 unity_SpecCube1_BoxMax;
//uniform float4 unity_SpecCube1_BoxMin;
//uniform float4 unity_SpecCube1_ProbePosition;
//uniform float4 unity_SpecCube1_HDR;
uniform float4 unity_ColorSpaceGrey;
//uniform float4 unity_ColorSpaceDouble;
uniform float4 unity_ColorSpaceDielectricSpec;
uniform float4 unity_ColorSpaceLuminance;
//uniform float4 unity_Lightmap_HDR;
uniform float4 unity_DynamicLightmap_HDR;
uniform float4 _LightColor0;
uniform float4 _SpecColor;
uniform mat4x4 unity_WorldToLight;
uniform float4 _Control_ST;
uniform float _Metallic0;
uniform float _Metallic1;
uniform float _Metallic2;
uniform float _Metallic3;
uniform float _Smoothness0;
uniform float _Smoothness1;
uniform float _Smoothness2;
uniform float _Smoothness3;
uniform float4 _Splat0_ST;
uniform float4 _Splat1_ST;
uniform float4 _Splat2_ST;
uniform float4 _Splat3_ST;
uniform sampler2D _Control;
uniform sampler2D _Splat0;
uniform sampler2D _Splat1;
uniform sampler2D _Splat2;
uniform sampler2D _Splat3;
uniform sampler2D _LightTexture0;
struct appdata_t
{
    float4 vertex :POSITION0;
    float3 normal :NORMAL0;
    float4 texcoord :TEXCOORD0;
};

struct OUT_Data_Vert
{
    float4 texcoord :TEXCOORD0;
    float4 texcoord1 :TEXCOORD1;
    float3 texcoord2 :TEXCOORD2;
    float3 texcoord3 :TEXCOORD3;
    float2 texcoord4 :TEXCOORD4;
    float4 vertex :SV_POSITION;
};

struct v2f
{
    float4 texcoord :TEXCOORD0;
    float4 texcoord1 :TEXCOORD1;
    float3 texcoord2 :TEXCOORD2;
    float3 texcoord3 :TEXCOORD3;
    float2 texcoord4 :TEXCOORD4;
};

struct OUT_Data_Frag
{
    float4 color :SV_Target0;
};

float4 t0;
float3 t1;
float t6;
OUT_Data_Vert vert(appdata_t in_v)
{
    OUT_Data_Vert out_v;
    out_v.vertex = UnityObjectToClipPos(in_v.vertex);
    out_v.texcoord.xy = TRANSFORM_TEX(in_v.texcoord.xy, _Splat0);
    out_v.texcoord.zw = TRANSFORM_TEX(in_v.texcoord.xy, _Splat1);
    out_v.texcoord1.xy = TRANSFORM_TEX(in_v.texcoord.xy, _Splat2);
    out_v.texcoord1.zw = TRANSFORM_TEX(in_v.texcoord.xy, _Splat3);
    t0.x = (in_v.normal.x * conv_mxt4x4_0(unity_WorldToObject).x);
    t0.y = (in_v.normal.x * conv_mxt4x4_1(unity_WorldToObject).x);
    t0.z = (in_v.normal.x * conv_mxt4x4_2(unity_WorldToObject).x);
    t1.x = (in_v.normal.y * conv_mxt4x4_0(unity_WorldToObject).y);
    t1.y = (in_v.normal.y * conv_mxt4x4_1(unity_WorldToObject).y);
    t1.z = (in_v.normal.y * conv_mxt4x4_2(unity_WorldToObject).y);
    t0.xyz = (t0.xyz + t1.xyz);
    t1.x = (in_v.normal.z * conv_mxt4x4_0(unity_WorldToObject).z);
    t1.y = (in_v.normal.z * conv_mxt4x4_1(unity_WorldToObject).z);
    t1.z = (in_v.normal.z * conv_mxt4x4_2(unity_WorldToObject).z);
    t0.xyz = (t0.xyz + t1.xyz);
    t0.xyz = normalize(t0.xyz);
    out_v.texcoord2.xyz = t0.xyz;
    t0.xyz = (in_v.vertex.yyy * conv_mxt4x4_1(unity_ObjectToWorld).xyz);
    t0.xyz = ((conv_mxt4x4_0(unity_ObjectToWorld).xyz * in_v.vertex.xxx) + t0.xyz);
    t0.xyz = ((conv_mxt4x4_2(unity_ObjectToWorld).xyz * in_v.vertex.zzz) + t0.xyz);
    out_v.texcoord3.xyz = ((conv_mxt4x4_3(unity_ObjectToWorld).xyz * in_v.vertex.www) + t0.xyz);
    out_v.texcoord4.xy = TRANSFORM_TEX(in_v.texcoord.xy, _Control);
    return out_v;
}

#define CODE_BLOCK_FRAGMENT
float4 t0_d;
float4 t10_0;
float3 t1_d;
float4 t16_1;
float4 t10_1;
float t16_2;
float4 t3;
float t16_3;
float4 t10_3;
float3 t16_4;
float3 t10_5;
float t16_7;
float3 t16_8;
float t16_13;
float2 t16_14;
float t16_18;
float t19;
float t16_20;
float t21;
OUT_Data_Frag frag(v2f in_f)
{
    OUT_Data_Frag out_f;
    t10_0 = tex2D(_Splat0, in_f.texcoord.xy);
    t10_1 = tex2D(_Control, in_f.texcoord4.xy);
    t16_2 = dot(t10_1, float4(1, 1, 1, 1));
    t16_3 = (t16_2 + 0.00100000005);
    t16_1 = (t10_1 / float4(t16_3, t16_3, t16_3, t16_3));
    t0_d = (t10_0 * t16_1.xxxx);
    t0_d.w = (t0_d.w * _Smoothness0);
    t10_3 = tex2D(_Splat1, in_f.texcoord.zw);
    t3 = (t16_1.yyyy * t10_3);
    t3.w = (t3.w * _Smoothness1);
    t0_d = (t0_d + t3);
    t10_3 = tex2D(_Splat2, in_f.texcoord1.xy);
    t3 = (t16_1.zzzz * t10_3);
    t3.w = (t3.w * _Smoothness2);
    t0_d = (t0_d + t3);
    t10_3 = tex2D(_Splat3, in_f.texcoord1.zw);
    t3 = (t16_1.wwww * t10_3);
    t16_8.x = dot(t16_1, float4(_Metallic0, _Metallic1, _Metallic2, _Metallic3));
    t3.w = (t3.w * _Smoothness3);
    t0_d = (t0_d + t3);
    t1_d.xyz = ((-in_f.texcoord3.xyz) + _WorldSpaceCameraPos.xyz);
    t19 = dot(t1_d.xyz, t1_d.xyz);
    t19 = rsqrt(t19);
    t3.xyz = ((-in_f.texcoord3.xyz) + _WorldSpaceLightPos0.xyz);
    t3.xyz = normalize(t3.xyz);
    t16_4.xyz = ((t1_d.xyz * float3(t19, t19, t19)) + t3.xyz);
    t16_14.x = dot(t16_4.xyz, t16_4.xyz);
    t16_1.x = max(t16_14.x, 0.00100000005);
    t16_14.x = rsqrt(t16_1.x);
    t16_4.xyz = (t16_14.xxx * t16_4.xyz);
    t16_14.x = dot(t3.xyz, t16_4.xyz);
    t16_14.y = dot(in_f.texcoord2.xyz, t3.xyz);
    t16_1.xy = max(t16_14.yx, float2(0, 0));
    t16_14.x = (t16_1.y * t16_1.y);
    t16_20 = ((-t0_d.w) + 1);
    t16_20 = (t16_20 * t16_20);
    t16_14.x = ((t16_14.x * t0_d.w) + t16_20);
    t16_18 = max(t16_20, 9.99999975E-05);
    t16_20 = (t16_18 * t16_18);
    t16_20 = (2 / t16_20);
    t16_20 = (t16_20 + (-2));
    t16_18 = max(t16_20, 9.99999975E-05);
    t16_14.x = (t16_14.x * 8);
    t16_7 = ((t16_14.x * t16_1.y) + 9.99999975E-05);
    t10_5.x = dot(in_f.texcoord2.xyz, in_f.texcoord2.xyz);
    t10_5.x = rsqrt(t10_5.x);
    t10_5.xyz = (t10_5.xxx * in_f.texcoord2.xyz);
    t16_14.x = dot(t10_5.xyz, t16_4.xyz);
    t16_13 = max(t16_14.x, 0);
    t16_14.x = log2(t16_13);
    t16_14.x = (t16_18 * t16_14.x);
    t16_20 = (t16_18 + 1);
    t16_14.x = exp2(t16_14.x);
    t16_14.x = (t16_14.x * t16_20);
    t16_18 = (t16_14.x / t16_7);
    t16_18 = max(t16_18, 9.99999975E-05);
    t16_18 = sqrt(t16_18);
    t16_14.x = min(t16_18, 100);
    t16_4.xyz = (t0_d.xyz + (-unity_ColorSpaceDielectricSpec.xyz));
    t16_4.xyz = ((t16_8.xxx * t16_4.xyz) + unity_ColorSpaceDielectricSpec.xyz);
    t16_8.x = (((-t16_8.x) * unity_ColorSpaceDielectricSpec.w) + unity_ColorSpaceDielectricSpec.w);
    t16_4.xyz = (t16_14.xxx * t16_4.xyz);
    t16_8.xyz = ((t0_d.xyz * t16_8.xxx) + t16_4.xyz);
    t16_4.xyz = (in_f.texcoord3.yyy * conv_mxt4x4_1(unity_WorldToLight).xyz);
    t16_4.xyz = ((conv_mxt4x4_0(unity_WorldToLight).xyz * in_f.texcoord3.xxx) + t16_4.xyz);
    t16_4.xyz = ((conv_mxt4x4_2(unity_WorldToLight).xyz * in_f.texcoord3.zzz) + t16_4.xyz);
    t16_4.xyz = (t16_4.xyz + conv_mxt4x4_3(unity_WorldToLight).xyz);
    t0_d.x = dot(t16_4.xyz, t16_4.xyz);
    t10_0.x = tex2D(_LightTexture0, t0_d.xx).w;
    t16_4.xyz = (t10_0.xxx * _LightColor0.xyz);
    t16_8.xyz = (t16_8.xyz * t16_4.xyz);
    t16_8.xyz = (t16_1.xxx * t16_8.xyz);
    out_f.color.xyz = (float3(t16_2, t16_2, t16_2) * t16_8.xyz);
    out_f.color.w = 1;
    return out_f;
}


ENDCG

}
 Pass {
  Name "DEFERRED"
  Tags { "LIGHTMODE"="Deferred" "QUEUE"="Geometry-99" "IGNOREPROJECTOR"="true" "RenderType"="Opaque" }
  ZWrite Off
  Blend One One
  GpuProgramID 175894
CGPROGRAM
//#pragma target 4.0

#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"
#define conv_mxt4x4_0(mat4x4) float4(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x,mat4x4[3].x)
#define conv_mxt4x4_1(mat4x4) float4(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y,mat4x4[3].y)
#define conv_mxt4x4_2(mat4x4) float4(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z,mat4x4[3].z)
#define conv_mxt4x4_3(mat4x4) float4(mat4x4[0].w,mat4x4[1].w,mat4x4[2].w,mat4x4[3].w)


#define CODE_BLOCK_VERTEX
//uniform float4 _Time;
//uniform float4 _SinTime;
//uniform float4 _CosTime;
//uniform float4 unity_DeltaTime;
//uniform float3 _WorldSpaceCameraPos;
//uniform float4 _ProjectionParams;
//uniform float4 _ScreenParams;
//uniform float4 _ZBufferParams;
//uniform float4 unity_OrthoParams;
//uniform float4 unity_CameraWorldClipPlanes[6];
//uniform mat4x4 unity_CameraProjection;
//uniform mat4x4 unity_CameraInvProjection;
//uniform float4 _WorldSpaceLightPos0;
//uniform float4 _LightPositionRange;
//uniform float4 unity_4LightPosX0;
//uniform float4 unity_4LightPosY0;
//uniform float4 unity_4LightPosZ0;
//uniform float4 unity_4LightAtten0;
//uniform float4 unity_LightColor[8];
//uniform float4 unity_LightPosition[8];
//uniform float4 unity_LightAtten[8];
//uniform float4 unity_SpotDirection[8];
//uniform float4 unity_SHAr;
//uniform float4 unity_SHAg;
//uniform float4 unity_SHAb;
//uniform float4 unity_SHBr;
//uniform float4 unity_SHBg;
//uniform float4 unity_SHBb;
//uniform float4 unity_SHC;
uniform float3 unity_LightColor0;
uniform float3 unity_LightColor1;
uniform float3 unity_LightColor2;
uniform float3 unity_LightColor3;
uniform float4x4 unity_ShadowSplitSpheres;
uniform float4 unity_ShadowSplitSqRadii;
//uniform float4 unity_LightShadowBias;
//uniform float4 _LightSplitsNear;
//uniform float4 _LightSplitsFar;
uniform mat4x4x4 unity_WorldToShadow;
//uniform float4 _LightShadowData;
// uniform float4 unity_ShadowFadeCenterAndType;
//uniform mat4x4 UNITY_MATRIX_MVP;
//uniform mat4x4 UNITY_MATRIX_MV;
//uniform mat4x4 UNITY_MATRIX_IT_MV;
//uniform mat4x4 unity_ObjectToWorld;
uniform mat4x4 unity_WorldToObject;
//uniform float4 unity_LODFade;
//uniform float4 unity_WorldTransformParams;
//uniform mat4x4 glstate_matrix_transpose_modelview0;
//uniform mat4x4 UNITY_MATRIX_P;
//uniform float4 glstate_lightmodel_ambient;
//uniform mat4x4 unity_MatrixV;
//uniform mat4x4 unity_MatrixVP;
//uniform float4 unity_AmbientSky;
//uniform float4 unity_AmbientEquator;
//uniform float4 unity_AmbientGround;
//uniform float4 unity_FogColor;
//uniform float4 unity_FogParams;
// uniform float4 unity_LightmapST;
// uniform float4 unity_DynamicLightmapST;
//uniform float4 unity_SpecCube0_BoxMax;
//uniform float4 unity_SpecCube0_BoxMin;
//uniform float4 unity_SpecCube0_ProbePosition;
//uniform float4 unity_SpecCube0_HDR;
//uniform float4 unity_SpecCube1_BoxMax;
//uniform float4 unity_SpecCube1_BoxMin;
//uniform float4 unity_SpecCube1_ProbePosition;
//uniform float4 unity_SpecCube1_HDR;
uniform float4 unity_ColorSpaceGrey;
//uniform float4 unity_ColorSpaceDouble;
uniform float4 unity_ColorSpaceDielectricSpec;
uniform float4 unity_ColorSpaceLuminance;
//uniform float4 unity_Lightmap_HDR;
uniform float4 unity_DynamicLightmap_HDR;
uniform float4 _LightColor0;
uniform float4 _SpecColor;
uniform float4 _Control_ST;
uniform float _Metallic0;
uniform float _Metallic1;
uniform float _Metallic2;
uniform float _Metallic3;
uniform float _Smoothness0;
uniform float _Smoothness1;
uniform float _Smoothness2;
uniform float _Smoothness3;
uniform float4 _Splat0_ST;
uniform float4 _Splat1_ST;
uniform float4 _Splat2_ST;
uniform float4 _Splat3_ST;
uniform float4 unity_Ambient;
uniform sampler2D _Control;
uniform sampler2D _Splat0;
uniform sampler2D _Splat1;
uniform sampler2D _Splat2;
uniform sampler2D _Splat3;
struct appdata_t
{
    float4 vertex :POSITION0;
    float3 normal :NORMAL0;
    float4 texcoord :TEXCOORD0;
};

struct OUT_Data_Vert
{
    float4 texcoord :TEXCOORD0;
    float4 texcoord1 :TEXCOORD1;
    float3 texcoord2 :TEXCOORD2;
    float3 texcoord3 :TEXCOORD3;
    float2 texcoord4 :TEXCOORD4;
    float4 texcoord6 :TEXCOORD6;
    float3 texcoord7 :TEXCOORD7;
    float4 vertex :SV_POSITION;
};

struct v2f
{
    float4 texcoord :TEXCOORD0;
    float4 texcoord1 :TEXCOORD1;
    float3 texcoord2 :TEXCOORD2;
    float2 texcoord4 :TEXCOORD4;
    float3 texcoord7 :TEXCOORD7;
};

struct OUT_Data_Frag
{
    float4 color :SV_Target0;
    float4 color1 :SV_Target1;
    float4 color2 :SV_Target2;
    float4 color3 :SV_Target3;
};

float4 t0;
float4 t16_0;
float3 t1;
float t16_2;
float3 t16_3;
float t12;
OUT_Data_Vert vert(appdata_t in_v)
{
    OUT_Data_Vert out_v;
    out_v.vertex = UnityObjectToClipPos(in_v.vertex);
    out_v.texcoord.xy = TRANSFORM_TEX(in_v.texcoord.xy, _Splat0);
    out_v.texcoord.zw = TRANSFORM_TEX(in_v.texcoord.xy, _Splat1);
    out_v.texcoord1.xy = TRANSFORM_TEX(in_v.texcoord.xy, _Splat2);
    out_v.texcoord1.zw = TRANSFORM_TEX(in_v.texcoord.xy, _Splat3);
    t0.x = (in_v.normal.x * conv_mxt4x4_0(unity_WorldToObject).x);
    t0.y = (in_v.normal.x * conv_mxt4x4_1(unity_WorldToObject).x);
    t0.z = (in_v.normal.x * conv_mxt4x4_2(unity_WorldToObject).x);
    t1.x = (in_v.normal.y * conv_mxt4x4_0(unity_WorldToObject).y);
    t1.y = (in_v.normal.y * conv_mxt4x4_1(unity_WorldToObject).y);
    t1.z = (in_v.normal.y * conv_mxt4x4_2(unity_WorldToObject).y);
    t0.xyz = (t0.xyz + t1.xyz);
    t1.x = (in_v.normal.z * conv_mxt4x4_0(unity_WorldToObject).z);
    t1.y = (in_v.normal.z * conv_mxt4x4_1(unity_WorldToObject).z);
    t1.z = (in_v.normal.z * conv_mxt4x4_2(unity_WorldToObject).z);
    t0.xyz = (t0.xyz + t1.xyz);
    t0.xyz = normalize(t0.xyz);
    out_v.texcoord2.xyz = t0.xyz;
    t1.xyz = (in_v.vertex.yyy * conv_mxt4x4_1(unity_ObjectToWorld).xyz);
    t1.xyz = ((conv_mxt4x4_0(unity_ObjectToWorld).xyz * in_v.vertex.xxx) + t1.xyz);
    t1.xyz = ((conv_mxt4x4_2(unity_ObjectToWorld).xyz * in_v.vertex.zzz) + t1.xyz);
    out_v.texcoord3.xyz = ((conv_mxt4x4_3(unity_ObjectToWorld).xyz * in_v.vertex.www) + t1.xyz);
    out_v.texcoord4.xy = TRANSFORM_TEX(in_v.texcoord.xy, _Control);
    out_v.texcoord6 = float4(0, 0, 0, 0);
    t16_2 = (t0.y * t0.y);
    t16_2 = ((t0.x * t0.x) + (-t16_2));
    t16_0 = (t0.yzzx * t0.xyzz);
    t16_3.x = dot(unity_SHBr, t16_0);
    t16_3.y = dot(unity_SHBg, t16_0);
    t16_3.z = dot(unity_SHBb, t16_0);
    out_v.texcoord7.xyz = ((unity_SHC.xyz * float3(t16_2, t16_2, t16_2)) + t16_3.xyz);
    return out_v;
}

#define CODE_BLOCK_FRAGMENT
float4 t0_d;
float4 t16_0_d;
float4 t10_0;
float4 t16_1;
float4 t10_1;
float t16_2_d;
float4 t3;
float t16_3_d;
float4 t10_3;
float3 t16_4;
float3 t16_5;
float3 t10_6;
float3 t16_9;
float t16_16;
OUT_Data_Frag frag(v2f in_f)
{
    OUT_Data_Frag out_f;
    t10_0 = tex2D(_Splat0, in_f.texcoord.xy);
    t10_1 = tex2D(_Control, in_f.texcoord4.xy);
    t16_2_d = dot(t10_1, float4(1, 1, 1, 1));
    t16_3_d = (t16_2_d + 0.00100000005);
    t16_1 = (t10_1 / float4(t16_3_d, t16_3_d, t16_3_d, t16_3_d));
    t0_d = (t10_0 * t16_1.xxxx);
    t0_d.w = (t0_d.w * _Smoothness0);
    t10_3 = tex2D(_Splat1, in_f.texcoord.zw);
    t3 = (t16_1.yyyy * t10_3);
    t3.w = (t3.w * _Smoothness1);
    t0_d = (t0_d + t3);
    t10_3 = tex2D(_Splat2, in_f.texcoord1.xy);
    t3 = (t16_1.zzzz * t10_3);
    t3.w = (t3.w * _Smoothness2);
    t0_d = (t0_d + t3);
    t10_3 = tex2D(_Splat3, in_f.texcoord1.zw);
    t3 = (t16_1.wwww * t10_3);
    t16_9.x = dot(t16_1, float4(_Metallic0, _Metallic1, _Metallic2, _Metallic3));
    t3.w = (t3.w * _Smoothness3);
    t0_d = (t0_d + t3);
    t16_16 = (((-t16_9.x) * unity_ColorSpaceDielectricSpec.w) + unity_ColorSpaceDielectricSpec.w);
    t16_4.xyz = (t0_d.xyz * float3(t16_16, t16_16, t16_16));
    out_f.color.xyz = (float3(t16_2_d, t16_2_d, t16_2_d) * t16_4.xyz);
    out_f.color.w = 1;
    t16_5.xyz = (t0_d.xyz + (-unity_ColorSpaceDielectricSpec.xyz));
    out_f.color1.w = (t16_2_d * t0_d.w);
    t16_9.xyz = ((t16_9.xxx * t16_5.xyz) + unity_ColorSpaceDielectricSpec.xyz);
    out_f.color1.xyz = (float3(t16_2_d, t16_2_d, t16_2_d) * t16_9.xyz);
    t10_6.xyz = ((in_f.texcoord2.xyz * float3(0.5, 0.5, 0.5)) + float3(0.5, 0.5, 0.5));
    out_f.color2.xyz = (float3(t16_2_d, t16_2_d, t16_2_d) * t10_6.xyz);
    out_f.color2.w = 1;
    t16_0_d.xyz = in_f.texcoord2.xyz;
    t16_0_d.w = 1;
    t16_5.x = dot(unity_SHAr, t16_0_d);
    t16_5.y = dot(unity_SHAg, t16_0_d);
    t16_5.z = dot(unity_SHAb, t16_0_d);
    t16_9.xyz = (t16_5.xyz + in_f.texcoord7.xyz);
    t16_9.xyz = max(t16_9.xyz, float3(0, 0, 0));
    t16_1.xyz = log2(t16_9.xyz);
    t16_1.xyz = (t16_1.xyz * float3(0.416666657, 0.416666657, 0.416666657));
    t16_1.xyz = exp2(t16_1.xyz);
    t16_1.xyz = ((t16_1.xyz * float3(1.05499995, 1.05499995, 1.05499995)) + float3(-0.0549999997, (-0.0549999997), (-0.0549999997)));
    t16_1.xyz = max(t16_1.xyz, float3(0, 0, 0));
    t16_9.xyz = (t16_4.xyz * t16_1.xyz);
    t16_0_d.xyz = exp2((-t16_9.xyz));
    t16_0_d.w = 1;
    out_f.color3 = (float4(t16_2_d, t16_2_d, t16_2_d, t16_2_d) * t16_0_d);
    return out_f;
}


ENDCG

}
}
Fallback "Hidden/TerrainEngine/Splatmap/Diffuse-AddPass"
}